package cc.tuhaolicai.mt.user.mobile.validator;
import cc.tuhaolicai.mt.user.mobile.controller.BaseController;
import com.google.common.collect.Maps;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

import java.util.Map;

/**
 * @version V1.0
 * @Title： BaseValidator
 * @Package： cc.tuhaolicai.mt.user.validator
 * @Description： BaseValidator.
 * @author： nan
 * @date： 2017-06-21 16:34
 */
public class BaseValidator extends Validator{

    private transient Map<String,String> errors = Maps.newHashMap();

    @Override
    protected void validate(Controller c) {}

    @Override
    protected void handleError(Controller c) {
        BaseController baseController = (BaseController) controller;
        baseController.renderJson(errors);
    }

    @Override
    protected void addError(String errorKey, String errorMessage) {
        invalid = true;
        errors.put(errorKey,errorMessage);
    }

}
